Repository navigation
M4b: shadcn-style defaults, named widgets, shell friction fixes - #17
Merged
Merged
Conversation
Build code can now read the egui local state a draw kept under an id from id_of (#15), and LayoutState::set_base_text changes or clears the base text between builds, so a theme switch can update an application's override. With no override the base still follows egui's style each build. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
bullseye::style::{Tokens, Shadcn} hold shadcn's new-york neutral tokens,
light and dark, all public and overridable. Shadcn::apply maps them onto the
egui Style of its theme (widget fills, strokes, radii, selection, text
colours, interact_size, button_padding, icon sizes) and remembers the tokens
in the context for what egui's style cannot express. The library never applies
a preset on its own.
- Inputs and selects are padded px-3 py-1 while buttons keep px-4 py-2: egui
shares one button_padding, so TextEdit and ComboBox take the preset's input
padding, in show and in the size estimates alike. Drift guards in
tests/sizing.rs now also run under both preset themes.
- Switch: an unlabelled switch is its track and follows the leaf's w/h
classes; thumb and travel scale with it. Default track is shadcn's 32x18.4
under the preset. Colours come from the tokens when a preset is applied.
- style::Shadcn::segmented gives the muted track and raised-cell classes for
prim::segmented.
- A single-line text field centres its line vertically in a taller leaf (#16);
multi-line stays top-aligned.
- named(...) on the stock widgets, Switch and select::Options sets the
accesskit label.
Intended behaviour changes: single-line field text moves to the leaf's
vertical centre, which regenerates the form, signup_form_empty and
signup_form_rejected goldens (only the typed text moved); an unlabelled
switch no longer has an interact_size.y floor.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The Unchecked mode of the test harness is gone: widgets are named with named(...) in the tests and the controls_gallery example. Adds the centring tests for single- and multi-line fields at several heights, font sizes and ppp, and a test that named primitives are found by their name. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The hand-rolled dark palette is gone. Tok keeps the app's own token names and resolves them from style::Tokens: Ground=background, Panel=card, Surface=muted, Hover=accent, Selected and Line=border, Ink=foreground, InkMid and InkDim=muted-foreground, Accent=primary, AccentHover=primary/90, OnAccent=primary-foreground. The palette is read from ctx.theme() at build time (Theme::of), so App no longer holds a theme; it holds an Appearance (System, Light, Dark) that prepare hands to ctx.set_theme. A segmented control with the preset's tab-list classes sets it, on its own line in the sidebar's account block. The base text colour comes from the root div, so set_base_text is only used by main. Behaviour changes: the composer's tool buttons hover with the border colour (accent equals the muted surface they sit on); the chat_shell golden is replaced by chat_shell_light and chat_shell_dark, and the composer goldens are re-rendered in the new palette, with a light scrolling variant added. Tests switch theme with real clicks and check the sidebar, the composer, a row mid hover transition and the model select's widget visuals, both ways. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
The shared runner applies Shadcn to both themes (light on the first frame, then egui's to change) and sets the base text from the tokens (14 pt text-sm). common's text_box, choice, menu_item, controls panel, focus ring (3 pt, ring at half opacity) and hover colours read the tokens instead of fixed greys; choice uses SegmentedClasses, wrapping above three options. Examples that took the old constants (form, signup_form, controls_gallery, flex_demos, flex_example, flexbox_guide) read tokens through Builder::ctx. The test harness applies the preset too, so tests and goldens see what the runner draws. Behaviour changes: base text 16 -> 14; the gallery's defaults become the preset's (button padding 16, 8; interact 40, 36; text 14) and its natural-size probes pad inputs as the preset does; hello's wrap test counts distinct line tops (it counted runs) and its select test scrolls the popup item into view (the popup now scrolls). Goldens changed: controls_gallery x3, form, signup_form x2, flex_demos x2, flex_example, flexbox_guide x4, port_button, port_custom_background, port_flex_grid, port_flex_wrap, port_grow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
29 tasks done
Owner
Author
|
Review follow-ups are tracked in #18. This PR stays a draft until they land and the user has approved fresh renders. |
…f, fit-content segments, clipped shadows (#18 items 3-10) Tokens: success/warning/info with foregrounds, destructive_foreground, and alpha steps (accent_50, muted_50, secondary_80, primary_90, destructive_90/60, input_30/50) as methods so overriding a token moves its steps. The hover and selected pairing per shadcn component is documented in the style module. Accent re-tints primary, primary-foreground, ring and the switch. Shadcn::of(ctx) returns the applied preset for the context's theme. SegmentedClasses is w-fit with cells that grow, and has a wrapping variant. A shadow is painted in the strips around the border box when the box does not cover it (CSS clips box-shadow to outside). Behaviour changes: selection.stroke is foreground (user's pick), so the selection fill is primary/30 to keep selected text readable; combo_height 400; dark pressed segment fill uses input_30. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Button gains primary, secondary (egui's own, the default), destructive, outline and ghost, drawn by restyling the Ui's widget visuals from the tokens (Shadcn::style_button), with the hover steps shadcn uses. Strokes and expansion are untouched, so the size estimate is the same for every variant; tests/sizing.rs checks that across variants. A disabled button is egui's half-opacity draw of its variant. Checkbox and radio under an applied preset: background (dark: input/30) fill with an input border; ticked is primary with a primary-foreground tick; the radio dot is primary. Labels keep the foreground colour. Behaviour change: with a preset applied, unticked checkboxes and radios no longer use the #e5e5e5 widget fill. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…, 11) Examples read the preset with Shadcn::of instead of repeating the token plumbing. chat_shell takes Accent::Blue (App::accent) and applies it every frame through Shadcn::apply_both_with: the context meter, send button and status markers use it, a Success/Danger pair colours +N/-M, hover is accent/50 and selected is accent. In dark the accent fill (shadcn's 800 shade) is too dim for text and small markers, so Tok::AccentText uses the ring shade there. The forms keep neutral chrome with a primary Save/Submit button and the accent's focus ring; the segmented tracks come from SegmentedClasses::wrapping. Goldens regenerated and reviewed: chat_shell (accent, semantic counts, hover), form and signup_form_* (primary button, checkbox look), controls_gallery_* (checkbox/radio, segmented fit), flex_* and flexbox_guide_* and port_flex_wrap (segmented tracks fit their cells, accent/50 hover). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…oser (#18 item 11) On the composer's muted surface the accent-coloured Selected token is the same colour, so the pressed cell vanished; it keeps the border colour. Goldens regenerated: chat_shell_* only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
… items 12, 15) shadcn's dark primary is the 700/800 shade, which is dim on near-black. In dark an accent's primary is now its 500 shade (the ring) with a black primary-foreground: the theme's own 50 and 950 shades reach 4.5:1 on it for only some of the colours (blue 3.5/3.9), black does for all (4.5 to 9.5). This departs from shadcn's registry and is documented on Accent. Neutral dark is unchanged. hyperlink_color is the ring in both themes. Behaviour changes: dark accent buttons, switches, meters and avatars are brighter; dark chat_shell goldens change; links take the ring colour. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…m 14) Ten cells (primary, secondary, destructive, outline, ghost, each enabled and disabled) take part in the size cross-check like the other cells. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…le (#18 item 17) The shared runner no longer forces Light on the first frame. A ThemeBar in examples/common (a strip with the shadcn segmented toggle) is shown by the shared runner and by every example with its own eframe loop (hello, kaolin, todo, known_gaps); chat_shell keeps its sidebar position but uses the same common::theme_toggle, so its Appearance state is gone and the egui context's theme preference is the one source. prim::segmented gains segmented_by for values that live outside the application. chat_shell's Tok::AccentText is now redundant with Accent and removed. Snapshots and tests set the theme explicitly. Behaviour changes: examples start in the OS theme; a toggle strip sits above every runner example; goldens are unchanged by this commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
ctx.data(|d| ... ctx.theme()) read the context's lock inside a closure that already held it. With another thread waiting to write the context that deadlocks, which parallel tests hit once a layout read the tokens while it was being built. The theme is now read first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Its prepare applies the examples' accent before setting the spacing, so the Primary cells are blue instead of black in light and grey in dark. Behaviour change: Primary button, checkbox, radio, switch and slider fills are blue in the three light goldens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Their hard-coded light palettes become the preset's tokens, read at build time, so the content is dark under the dark theme too. button: fills are secondary / border (hover) / ring (pressed) and the selected button is primary (it was blue; neutral accent equals secondary so it could not be told apart). todo: rows muted, border input, hover border, action hover ring/50, pressed ring, text foreground / muted-foreground. kaolin: gallery sidebar muted with a border, stage background; layouts take their greys from the theme (panel muted, deeper grey ring, card card) and keep the demo colours (blues, dark grey footer, black embedded stage). known_gaps: chrome follows the theme; the shadow comparison sits on a light stage in both themes because black 5-10% shadows are invisible on near-black. Intentional golden changes (light): button selected fill blue to primary and greys to tokens; todo border 208 to e5e5e5, muted text, hover fills; kaolin LIGHT_GRAY (dcdcdc) panels to muted (f5f5f5), text to foreground; known_gaps shadow section f3f4f6 to f5f5f5 and shifted 24px by the stage padding. New dark goldens for each, a themed page for dark goldens, and tests/themed_examples.rs asserting the surfaces per theme. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Each row was a fixed h_px(26.0) div_id adding a stock selectable egui
button with add_sized, so the library never measured it; under the preset
egui's 36pt minimum button height spilled over the next row. Rows are now
b.widget leaves holding widget::Button, sized by the library.
widget::Button gains a selectable form, Button::selectable(label, Mark),
with the size of a button in either state (egui forces the frame of a
selectable button, so Stock::size does too: a drift guard case covers it).
Mark is public so the state is not a naked bool. The other examples hold
no hand-sized stock widgets in class-sized leaves; the controls_gallery
egui::* calls are the deliberate reference column that the estimate is
compared with.
Test: the sidebar rows are disjoint and each drawn button is inside its
row, with and without the preset, light and dark (it failed before).
kaolin_gallery_{light,dark} goldens change: rows are 36pt tall.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…item 22) The preset sets handle_shape = Circle and slider_trailing_fill = true. widget::Slider scopes the rest inside its own Ui: track muted, range primary, thumb a 1pt primary outline round an opaque background fill (shadcn's size-4 rounded-full border border-primary bg-background), so no other widget's colours change. egui paints the rail and the resting thumb with the same inactive.bg_fill, so after drawing the slider the circle's fill is set to background. The thumb is 16pt (Tokens::slider_thumb): egui's circular handle is 0.4 of the slider's height, so the slider is Tokens::slider_height() = 20pt tall under the preset, and Stock::size and the drift guard (tests/sizing.rs, controls_gallery's egui reference column) follow. Audit of egui widgets that paint with bg_fill: only the slider thumb differs from shadcn. Checkbox and radio (dark input/30), DragValue, ComboBox and TextEdit (dark input/30) are translucent in shadcn too. Behaviour changes: sliders are 20pt tall under the preset (was 36pt); the rail height stays egui's. Tests: tests/widget_looks.rs (thumb shape, fill, stroke, trailing fill and track, light and dark, at rest and hovered; a sibling button's shapes and the global style are unchanged). Goldens: controls_gallery x4, flex_example, port_custom_background, port_flex_grid, port_flex_wrap, port_grow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
… 19) shadcn's link button is text-primary with an underline on hover. This reverses item 15, which used ring. The test now asserts hyperlink = primary for every accent in both themes, and primary against background at 4.5:1. Violet in dark is 4.498:1 (violet-500 on #0a0a0a), a hair under; it is a named exception at 4.49 in the test, since the colour is the user's to change. Every other accent clears 4.5 in both themes. No goldens change: no example draws a hyperlink. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
widget::Button::selectable draws as shadcn's Toggle: transparent at rest,
muted with muted-foreground text on hover, accent with accent-foreground
text while selected, which keeps the fill under the pointer. egui paints
a selected button from selection.bg_fill, which also colours selected text,
so the look is set in the button's own Ui and the global selection is
untouched. The button example's selectable demo takes the same tokens
(Fills::selected is gone; it senses clicks explicitly, as hover alone does
not).
Behaviour changes: the selectable button example loses its border and
secondary fill; kaolin's selected sidebar row is accent, which in the
neutral palette equals the sidebar's muted, so it no longer shows.
Accent is not renamed (M4c).
Tests: tests/widget_looks.rs (rest, real-pointer hover and selected fill
and text colour, light and dark; text selection colours unchanged); the
button example's port and themed tests follow the new tokens.
Goldens: port_button, port_button_dark, kaolin_gallery_{light,dark}.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…#18 item 24) In neutral the selected row (accent) equals muted, so on a muted sidebar it vanished. The sidebar is now background, as in shadcn's sidebar block, keeping the border-r edge. The themed test asserts the sidebar fill and that it differs from accent in light and dark. Goldens kaolin_gallery_{light,dark} regenerated: the sidebar fill and the now-visible selected row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…exception (#18 item 25) Dark violet primary (also the link colour and ring) goes from #8e51ff (4.498:1 on #0a0a0a) to #8e52ff (4.53:1), the smallest lightness step that reaches AA, hue kept. Black label on it is 4.8:1. The hyperlink contrast test no longer names Violet/Dark; every accent meets 4.5:1. The nudge is documented on Accent. No golden changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Each details section keeps its small uppercase header, and its rows now sit in a rounded, bordered group on the `background` surface, separated by `divide_y` hairlines. Rows are `px-3 py-2` with the label left and the value right. The Context meter shares one row with its label, so no hairline falls between them. Built from existing classes; no library change. The group is `background` rather than `card`: the panel is `card`, which in light is the same white, so a `card` group would be border-only, and in dark `background` reads as an inset field against the lighter panel. Adds Part::Group and Part::Row(label) so tests address the rows by path; the meter's path gains the two segments. New test asserts shape-based divide lines between (and only between) rows and right-aligned values at the group's padding edge, in both themes. Goldens regenerated: chat_shell light/dark and the three composer variants (details panel only). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…#18 item 27) The light goldens drew no page, so wherever the layout painted nothing the harness's transparent clear colour showed (black in most viewers). The live examples paint a themed central panel across the whole window. Page::Themed is now used for every golden that renders an example, in both themes, and fills the whole window rather than only the layout's area, so the 8-point margin the harness leaves around the layout is painted too. Goldens changed: controls_gallery_{narrow,default,wide,dark}, port_button{,_dark}, port_custom_background, port_sidebar, port_flex_grid, port_flex_wrap, port_grow, flex_demos_{horizontal,vertical_grow}, flex_example, flexbox_guide_*, todo_row_hovered{,_dark}, form, signup_form_{empty,rejected}, chat_shell_*, kaolin_gallery_{light,dark}, known_gaps_shadows{,_dark}, port_flex, port_holy_grail. Only previously unpainted or translucent pixels change, except port_flex and port_holy_grail: they were rendered under egui's dark theme with a light page, so their text antialiasing differed from the live light-theme app; they now go through the same light rig as the rest (text edge pixels only, max channel delta 64). known_gaps_shadows now goes through the shared rig instead of its own harness. Left alone: kaolin_* layout tests, chrome_stacked_by_z and kaolin_embedded_layout are library layout renderings, not the live examples (the live kaolin example is covered by kaolin_gallery_*). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
samitbasu
marked this pull request as ready for review
November 8, 2026 19:25
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1. Closes #15, closes #16.
Library
bullseye::style:Tokens/Shadcnhold the shadcn new-york neutral palette, light and dark. Every token is public and overridable.apply(ctx)/apply_both. The library never changes egui's style on its own.switchtakes its track size from itsw/hclasses, defaulting to shadcn's 32×18.4.SegmentedClassesgives segmented controls the tabs/toggle-group look.named(...)on every stock widget and prim (thearia-labelequivalent). kittest's accessibility check is back on in every test file.Builder::ctx()(Builder has no ctx(), so build cannot read local UI state (D11, §6) #15).LayoutState::set_base_text(Option<TextStyle>), so the base text can change per build.Examples
chat_shellfollows light and dark.chat_shell_light,chat_shell_dark,chat_shell_composer_scrolling_light.Where egui can't match shadcn (documented in the module)
focusvariant.shadow-xson stock inputs, and no medium-weight text (Font weights (font-medium / font-semibold) have no faces; headings fall back to Regular #13).For review before ready
The before/after renders were shared with the user. The aesthetic questions are listed in the conversation.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up